package test8;

import java.util.*;

public class Demo1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        List<int[]> blocks = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int s = in.nextInt();
            int e = in.nextInt();
            blocks.add(new int[]{s, e});
        }
        Collections.sort(blocks, Comparator.comparingInt(l -> l[1]));
        List<int[]> gp = new ArrayList<>();
        gp.add(blocks.get(0));
        for (int i = 1; i < blocks.size(); i++) {
            int b[] = blocks.get(i);
            boolean live = true;
            List<Integer> del = new ArrayList<>();
            for (int j = 0; j < gp.size(); j++) {
                int g[] = gp.get(j);
                if (b[0] <= g[0] && b[1] >= g[1]) {
                    del.add(j);
                } else if (b[0] >= g[0] && b[1] <= g[1]) {
                    live = false;
                }
            }
            for (int ind = del.size() - 1; ind >= 0; ind--) {
                gp.remove(ind);
            }
            if (live) {
                gp.add(b);
            }
        }
        System.out.println(gp.size());
    }
}

